﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RanchBuddy.Core.Services.Impl;

namespace RanchBuddy.Web.Services
{
    public class MyViewPage : ViewPage
    {
        protected override void OnPreInit(EventArgs e)
        {
            MasterPageFile = MyViewPageHelper.GetMasterpage();
            Theme = ConfigurationService.ThemeToUse().ToString();

            base.OnPreInit(e);
        }
    }

    public class MyViewPage<T> : ViewPage<T> where T : class
    {
        protected override void OnPreInit(EventArgs e)
        {

            MasterPageFile = MyViewPageHelper.GetMasterpage();
            Theme = ConfigurationService.ThemeToUse().ToString();

            base.OnPreInit(e);
        }
    }

    public class MyViewPageHelper
    {
        public static string GetMasterpage()
        {
            string result;
            if (ConfigurationService.MasterTemplateToUse() == ConfigurationService.MasterTemplateTypes.RanchBuddy)
                result = "~/Views/Shared/RanchBuddy.master";
            else
                result = "~/Views/Shared/Site.master";

            return result;
        }
    }
}